﻿@using ST = EmoneyWeiXinCommon.StringTools;
@{
    ViewBag.Title = "PanHouTJGManage";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="right">
    <h3>盘后推荐股管理</h3>
    <!--manage-->
    <div class="manage">
        <!--manage_top-->
        <div class="manage_top">
            <div class="manage_register">
                <p><span>股票名称：</span><input type="text" id="stockName"></p>
                <p><span>股票代码：</span><input type="text" id="stockCode"></p>
            </div>
            <div class="manage_register">
                <p></p>
                <p>
                    <input type="button" value="设置为推荐股" id="btnSetTJG">
                </p>
            </div>
        </div>
        <!--manage_top end-->
        <p class="manage_line"></p>
        <!--manage_bottom-->
        <div class="manage_bottom">
            <!--manage_bottom_title-->

            <!--manage_bottom_title end-->
            <table border="0" cellpadding="0" cellspacing="0" width="100%" id="dtTable">
                <tr>
                    <th><span>股票名称</span></th>
                    <th><span>股票编码</span></th>
                    <th><span>添加时间</span></th>
                    <th><span>操作</span></th>
                </tr>
                <tbody id="dvList">
                </tbody>
            </table>
            @*<div class="manage_page" id="manage_page">
            </div>
            <p class="manage_page_font">共 <span id="divRecord"></span>条记录</p>*@
        </div>
        <!--manage_bottom end-->
    </div>
    <!--manage end-->
</div>
<script type="text/javascript">
    $(function () {
        initEvent();
        BindData();
    });

    function initEvent() {
        $("#btnSetTJG").click(function () {
            var $stockName = $("#stockName");
            var $stockCode = $("#stockCode");
            $.ajax({
                url: '@Url.Action("PanHouTJGAdd", "WXUser")',
                data: { stockName: $stockName.val(), stockCode: $stockCode.val() },
                type: 'post',
                success: function (data) {
                    if (data == "1") {
                        BindData();
                        alert("设置成功");
                    } else {
                        alert("设置失败");
                    }
                }
            });
        });
    }
    //获取数据
    function BindData() {
        $.ajax({
            url: '@Url.Action("GetListPHTJG", "WXUser")',
            data: {},
            type: 'post',
            dataType: 'json',
            success: function (data) {
                var $table = $("#dtTable");
                $table.find("tr:gt(0)").remove();
                for (var i = 0; i < data.length; i++) {
                    var $newTr = $("<tr><td>" + data[i].stockName + "</td><td>" + data[i].stockCode + "</td><td>" + data[i].updateTime + "</td><td>&nbsp</td></tr>");
                    $table.append($newTr);
                }
            }
        });
    }
</script>
